// 查看视频完整版
$('.img-btn-download').on('click', function() {
  _hmt.push(['_trackEvent', 'tv_all', 'click', '0']);
});

//分享朋友圈
$('.img-btn-download').on('click', function() {
  _hmt.push(['_trackEvent', 'share_friend', 'click', '0']);
});

//关注主播
$('.img-btn-zhubo').on('click', function() {
  _hmt.push(['_trackEvent', 'zhubo', 'click', '0']);
});

$(function () {
  //观看封面视频
  if(isPhone == 'true'){
    var tvBig = document.getElementById('tv');
    var tv1 = document.getElementById('tv1');
    var tv2 = document.getElementById('tv2');
    var tv3 = document.getElementById('tv3');
    var tv4 = document.getElementById('tv4');

    $('.img-tv-poster').on('click',function () {
      var bigHeight = $('.img-tv-poster').height();
      tvBig.height = bigHeight;
      $('.img-tv-poster').hide();
      tvBig.play();
      tv1.pause();
      tv2.pause();
      tv3.pause();
      tv4.pause();
      $('.video-big').show();
    })

    $('.tv-poster-1').on('click',function () {
      var tv1Height = $('.tv-poster-1').height();
      tv1.height = tv1Height;
      $('.tv-poster-1').hide();
      tv1.play();
      tvBig.pause();
      tv2.pause();
      tv3.pause();
      tv4.pause();
      $('.video-1').show();
    })

    $('.tv-poster-2').on('click',function () {
      var tv2Height = $('.tv-poster-2').height();
      tv2.height = tv2Height;
      $('.tv-poster-2').hide();
      tv2.play();
      tv1.pause();
      tvBig.pause();
      tv3.pause();
      tv4.pause();
      $('.video-2').show();
    })

    $('.tv-poster-3').on('click',function () {
      var tv3Height = $('.tv-poster-3').height();
      tv3.height = tv3Height;
      $('.tv-poster-3').hide();
      tv3.play();
      tv1.pause();
      tv2.pause();
      tvBig.pause();
      tv4.pause();
      $('.video-3').show();
    })

    $('.tv-poster-4').on('click',function () {
      var tv4Height = $('.tv-poster-4').height();
      tv4.height = tv4Height;
      $('.tv-poster-4').hide();
      tv4.play();
      tv1.pause();
      tv2.pause();
      tv3.pause();
      tvBig.pause();
      $('.video-4').show();
    })

    //视频暂停
    tvBig.addEventListener('pause',function () {
      $('.img-tv-poster').show();
      $('.video-big').hide();
    })

    tv1.addEventListener('pause',function () {
      $('.tv-poster-1').show();
      $('.video-1').hide();
    })

    tv2.addEventListener('pause',function () {
      $('.tv-poster-2').show();
      $('.video-2').hide();
    })

    tv3.addEventListener('pause',function () {
      $('.tv-poster-3').show();
      $('.video-3').hide();
    })

    tv4.addEventListener('pause',function () {
      $('.tv-poster-4').show();
      $('.video-4').hide();
    })
  }else{
    $('.img-tv-poster').on('click',function () {
      window.location.href="http://video.lalocal.cn/h5/nmghd.mp4";
    })
    $('.tv-poster-1').on('click',function () {
      window.location.href="http://video.lalocal.cn/h5/bxndmday1.mp4";
    })
    $('.tv-poster-2').on('click',function () {
      window.location.href="http://video.lalocal.cn/h5/xmdsday2.mp4";
    })
    $('.tv-poster-3').on('click',function () {
      window.location.href="http://video.lalocal.cn/h5/elsxcday3.mp4";
    })
    $('.tv-poster-4').on('click',function () {
      window.location.href="http://video.lalocal.cn/h5/ghaxjlday4.mp4";
    })
  }

  //下载app
  $('.img-btn-download').on('click',function () {
    if(isApp == 'true'){
      window.location.href='lalocal://app?{"targetType": "20","targetId": "4593","targetUrl": "https://dev.lalocal.cn/wechat/app_theme?id=35"}'
    }else{
      window.location.href='http://a.app.qq.com/o/simple.jsp?pkgname=com.lalocal.lalocal';
    }
  })

  $('.img-btn-zhubo').on('click',function () {
    if (isApp == 'true') {
      window.location.href='lalocal://app?{"targetType": "0","targetId": "9026","targetUrl": "https://dev.lalocal.cn/wechat/app_theme?id=35"}'
    }else{
      window.location.href='http://a.app.qq.com/o/simple.jsp?pkgname=com.lalocal.lalocal';
    }
  })

  //取消图片滑动
  $('.view-box').on('touchmove',function () {
    $('.img-tip').fadeOut(1000).removeClass('img-move');
  })

  //提示分享
  $('.img-btn-share').on('click',function () {
    $('.share-box').show();
  })

  //关闭分享提示
  $('.share-box').on('click',function () {
    $('.share-box').hide();
  })
})
